﻿using System.Collections.Generic;
using NetBay.Core.BusinessEntities;
using System.Data;
using Rio.Framework.RioManager.Repository.Translator;
namespace Rio.Framework.RioManager
{
    public class SettingsRepository
    {

        public static List<Setting> Init(string p_sPackageName)
        {
            List<Setting> l_oSettings = new List<Setting>();
            // Load all settings from DB
            IDataReader dbrDataSettings = DA_Settings.Load(p_sPackageName);
            // Check if we have a valid reference for data to read
            if (dbrDataSettings != null)
            {
                // Anything to read?
                Setting cSetting;
                // Convert it to an array of Setting object
                do
                {
                    // Convert a row to a Setting classe
                    cSetting = SettingsTranslator.cTranslateSetting(dbrDataSettings);
                    if (cSetting.ErrorCode != (int)ReturnObject.ErrorCodes.Success)
                        // No more Settings to convert
                        break;
                    // Added to array
                    l_oSettings.Add(cSetting);
                }
                while (true);
            }
            return l_oSettings;
        }


    }
}
